<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
	<link rel="stylesheet" href="index.css"></link>
</head>
<body>
    <div class="msg"></div>
	<audio 
		style="display:none; height: 0" 
		id="bg-music" preload="auto"
		loop="loop">
	</audio>
	<script>
		console.log(111)
		//展示内容
		function demo(date){
		console.log(111)
			let data=date.list
			var str = "";
			for (let i = 0; i < data.length; i++) {
				if(data[i].type=="1"){
					str +='<div class="title">'+data[i].text+'</div>'
				}else if(data[i].type=='2'){
					str +='<div class="left_title">'+data[i].text+'</div>'
				}else if(data[i].type=='3'){
					str +='<p class="con_text">'+data[i].text+'</p>'
				}else if(data[i].type=='4'){
					str +='<img class="con_img" src="'+data[i].img+'">'
					str +='<p class="con_img_text">'+data[i].text+'</p>'
				}else if(data[i].type=='5'){
					var audio = document.getElementById('bg-music');
					audio.src=data[i].url
					console.log(audio)
					this.autoPlayMusic();
					this.audioAutoPlay();
					document.querySelector(".msg").onclick= function (){
						autoPlayMusic();
						audioAutoPlay();
					}
				}
			};
			setTimeout(()=>{
				document.querySelector(".msg").innerHTML = str;
			},0)
		}
		
		
		function audioAutoPlay() {
			var audio = document.getElementById('bg-music');
			audio.play();
			document.addEventListener("WeixinJSBridgeReady", function () {
				audio.play();
			}, false);
		}
		// 音乐播放
		function autoPlayMusic() {
			// 自动播放音乐效果，解决浏览器或者APP自动播放问题
			function musicInBrowserHandler() {
				musicPlay(true);
				document.body.removeEventListener('touchstart', musicInBrowserHandler);
			}
			document.body.addEventListener('touchstart', musicInBrowserHandler);
			// 自动播放音乐效果，解决微信自动播放问题
			function musicInWeixinHandler() {
				musicPlay(true);
				document.addEventListener("WeixinJSBridgeReady", function () {
					musicPlay(true);
				}, false);
				document.removeEventListener('DOMContentLoaded', musicInWeixinHandler);
			}
			document.addEventListener('DOMContentLoaded', musicInWeixinHandler);
		}

		function musicPlay(isPlay) {
			var media = document.querySelector('#bg-music');
			if (isPlay && media.paused) {
				media.play();
			}
			if (!isPlay && !media.paused) {
				media.pause();
			}
		}
	</script>
	<script type="text/javascript" src="./index.json?cb=demo" /></script>
</body>
</html>